package item

import (
	. "game_server/logic/internal"
	"game_server/model"
	"proto/item"
)

type itemService struct {
}

func init() {
	Service.Register(new(itemService))
}

func (*itemService) Name() string {
	return "proto_item"
}

func (*itemService) SyncData(player *model.Player, request *proto_item.SyncData) (err error) {
	response := new(proto_item.SyncData)
	response.Table = make(map[int32]uint32)
	for _, item := range player.Item.Data {
		response.Table[item.Id] = item.Count
	}

	rpc.SyncData(player, response)

	return
}
